using System.Web.Mvc;
using TestBat.Frontend.Controllers.ViewData.Overview;
using TestBat.IModels.Domain;
using TestBat.IModels.Models;

namespace TestBat.Frontend.Controllers
{
    [Authorize]
    public class OverviewController : Controller
    {
        public OverviewController(IScheduleModel scheduleModel, ITraineeModel traineeModel, ITestModel testModel)
        {
            this.scheduleModel = scheduleModel;
            this.traineeModel = traineeModel;
            this.testModel = testModel;
        }

        public ActionResult Index()
        {
            IndexViewData vd = new IndexViewData();

            return View(vd);
        }

        public ActionResult Schedules()
        {
            SchedulesViewData vd = new SchedulesViewData();

            // get trainee
            ITrainee trainee = traineeModel.GetByUsername(User.Identity.Name);

            vd.Schedules = scheduleModel.GetRunningForTrainee(trainee);

            return View(vd);
        }

        public ActionResult Results()
        {
            ResultsViewData vd = new ResultsViewData();

            // get trainee
            ITrainee trainee = traineeModel.GetByUsername(User.Identity.Name);

            vd.Tests = testModel.GetGradedForTrainee(trainee);

            return View(vd);
        }

        private readonly IScheduleModel scheduleModel;
        private readonly ITraineeModel traineeModel;
        private readonly ITestModel testModel;
    }
}
